﻿using Dora.Orm.Core.Domain.Entities;
using Dora.Tools.Enums.AdminUser;
using Dora.Tools.Utility;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;

namespace Dora.Services.AdminUser.Dto.ViewDto
{
    /// <summary>
    /// 机构文档表ViewDto
    /// </summary>
    public class OrgDocViewDto
    {
        #region model

        /// <summary>
        /// 主键
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 顶级机构Id;即大社
        /// </summary>
        public int TopOrgId { get; set; }

        /// <summary>
        /// 机构Id;上传人所在orgid
        /// </summary>
        public int OrgId { get; set; }

        /// <summary>
        /// 文档类型;1系统文档2企业文档
        /// </summary>
        public int Type { get; set; }

        /// <summary>
        /// 文档名
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 文档扩展名
        /// </summary>
        public string DocExt { get; set; }

        /// <summary>
        /// 文档大小;单位字节B
        /// </summary>
        public int DocSize { get; set; }

        /// <summary>
        /// 文档地址
        /// </summary>
        public string DocUrl { get; set; }

        /// <summary>
        /// 预览地址
        /// </summary>
        public string PreviewUrl { get; set; }

        /// <summary>
        /// 排序;倒序
        /// </summary>
        public int Sort { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        public string CreatedUserName { get; set; }
        /// <summary>
        /// 创建人
        /// </summary>
        public Guid? CreatedUserId { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreatedTime { get; set; }

        #endregion
        #region extend

        /// <summary>
        /// 组织机构名称
        /// </summary>
        public string OrgName { get; set; }

        /// <summary>
        /// 组织机构缩略名称
        /// </summary>
        public string OrgShortName { get; set; }

        /// <summary>
        /// 上传者
        /// </summary>
        public string UploadAuthor
        {
            get
            {
                if (!string.IsNullOrWhiteSpace(OrgShortName))
                {
                    return $"{OrgShortName}-{CreatedUserName}";
                }
                else if (!string.IsNullOrWhiteSpace(OrgName))
                {
                    return $"{OrgName}-{CreatedUserName}";
                }
                return CreatedUserName;
            }
        }
        #endregion
    }
}
